package com.systop.supervise.mapper;
import com.systop.common.pojo.performance;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
@Mapper
public interface PerformanceMapper {

    //1 添加
    @Insert("insert into performance (sno,elective_course_id,tno,performance_rule_id,peacetime_performance,mid_term_performance,final_performance,skill_assessment,total_score,pass_flag,allow_flag,remark)" +
            " values (#{sno},#{elective_course_id},#{tno},#{performance_rule_id},#{peacetime_performance},#{mid_term_performance},#{final_performance},#{skill_assessment},#{total_score},#{pass_flag},#{allow_flag},#{remark})")
    int performanceadd(performance p);

    // 2通过tno查list
    @Select("select * from performance where tno=#{tno}")
    List<performance> performancetno(String tno);

    //3通过成绩id 查list
    @Select("select * from performance where performance_id=#{performance_id}")
    List<performance> performance_id_list(int performance_id);

    //3-1通过成绩id 查 实体
    @Select("select * from performance where performance_id=#{performance_id}")
    performance performance_id_p(int performance_id);

    //3-2通过排课id查list
    @Select("select * from performance where elective_course_id=#{elective_course_id}")
    List<performance> paikeId_tno(int elective_course_id);

    //4 通过成绩id修改
    @Update("update performance set sno=#{sno},elective_course_id=#{elective_course_id}," +
            "tno=#{tno},performance_rule_id=#{performance_rule_id},peacetime_performance=#{peacetime_performance}," +
            "mid_term_performance=#{mid_term_performance},final_performance=#{final_performance},skill_assessment=#{skill_assessment}," +
            "total_score=#{total_score},pass_flag=#{pass_flag},allow_flag=#{allow_flag},remark=#{remark} where performance_id = #{performance_id}")
    int performanceUp(performance p);

    //5通过sno和排课id和状态sno elective_course_id allow_flag
    @Select("select * from performance where sno=#{sno} and elective_course_id=#{elective_course_id} and allow_flag=#{allow_flag}")
    List<performance> sno_pkid_allow(performance p);

   //6通过tno修改 发布成绩
    @Update("update performance set allow_flag=#{allow_flag} WHERE  tno = #{tno}")
    int allow_flagfabu(performance p);

    //5 查询所有
    @Select("select * from performance")
    List<performance> performanceall();
    //6通过id删除
    @Delete("delete from performance where performance_id=#{performance_id}")
    int performancedel(Integer performance_id);
}
